package com.whjz.dcfs.ggts.struts.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.whjz.dcfs.ggts.dao.IDcfsGgtsJbxxDAO;
import com.whjz.dcfs.ggts.model.DcfsGgtsJbxx;
import com.whjz.dcfs.jzxx.model.DcfsHjjcdJbxx;
import com.whjz.dcfs.util.BaseAction;
import com.whjz.dcfs.util.UserUtil;

public class JZGGTSAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	@Autowired
	private IDcfsGgtsJbxxDAO dcfsGgtsJbxxDAO;
	
	private DcfsGgtsJbxx dcfsGgtsJbxx;

	public void getDcfsTsclJbxxListByCond() throws Exception{
		getHttpServletResponse().setCharacterEncoding("utf-8");
		String xzqh=UserUtil.findUserFromSession(getSession().get("user"),"getConcern");
		if(xzqh.indexOf("区")!=-1){
			dcfsGgtsJbxx=new DcfsGgtsJbxx();
			dcfsGgtsJbxx.setTssbssqy(xzqh);
		}
		List<DcfsGgtsJbxx> list=dcfsGgtsJbxxDAO.getDcfsGgtsJbxxListByCond(dcfsGgtsJbxx);
		StringBuffer sb=new StringBuffer();
		sb.append("{root:[");
		if(list!=null&&list.size()>0){
			for(int i=0;i<list.size();i++){
				sb.append("{");
				sb.append("TS_BH:'"+list.get(i).getTsbh()+"',");
				sb.append("TS_SJ:'"+list.get(i).getTssj()+"',");
				sb.append("TS_R:'"+(list.get(i).getTsr()==null?"":list.get(i).getTsr())+"',");
				sb.append("TS_DD:'"+(list.get(i).getTsdd()==null?"":list.get(i).getTsdd())+"',");
				sb.append("TS_R_LXDH:'"+(list.get(i).getTsrlxdh()==null?"":list.get(i).getTsrlxdh())+"',");
				sb.append("TS_SB_SSQY:'"+list.get(i).getTssbssqy()+"',");
				sb.append("TS_SB_LX:'"+list.get(i).getTssblx()+"',");
				sb.append("TS_SB_MC:'"+list.get(i).getTssbmc()+"',");
				sb.append("TS_SB_BH:'"+list.get(i).getTssbbh()+"',");
				sb.append("TS_QKMS:'"+(list.get(i).getTsqkms()==null?"":list.get(i).getTsqkms())+"',");
				sb.append("TS_BZ:'"+(list.get(i).getTsbz()==null?"":list.get(i).getTsbz())+"',");
				sb.append("TS_ZT:'"+list.get(i).getTszt()+"'");
				sb.append("}");
				if(i < list.size()-1){
					sb.append(",");
				}
			}
		}
	     sb.append("]}");
	     getHttpServletResponse().getWriter().print(sb);
	}
	
	
	public void insertDcfsGgtsJbxx() throws Exception{
		try{
			dcfsGgtsJbxxDAO.insertDcfsGgtsJbxx(dcfsGgtsJbxx);
			getHttpServletResponse().getWriter().println("{success:'true',msg:'添加成功'}");
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void updateDcfsGgtsJbxx() throws Exception{
		try{
			dcfsGgtsJbxxDAO.updateDcfsGgtsJbxx(dcfsGgtsJbxx);
			getHttpServletResponse().getWriter().println("{success:'true',msg:'更新成功'}");
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void deleteDcfsGgtsJbxxByCond() throws Exception{
		try{
			dcfsGgtsJbxxDAO.deleteDcfsGgtsJbxxByCond(dcfsGgtsJbxx);
			getHttpServletResponse().getWriter().println("{success:'true',msg:'删除成功'}");
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void updateDcfsGgtsJbxx_tscl() throws Exception{
		try{
			dcfsGgtsJbxxDAO.updateDcfsGgtsJbxx_tscl(dcfsGgtsJbxx);
			getHttpServletResponse().getWriter().println("{success:'true',msg:'处理成功'}");
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void updateDcfsGgtsJbxx_tsfb() throws Exception{
		try{
			dcfsGgtsJbxxDAO.updateDcfsGgtsJbxx_tsfb(dcfsGgtsJbxx);
			getHttpServletResponse().getWriter().println("{success:'true',msg:'发布成功'}");
		}catch(Exception e){
			e.printStackTrace();
		}
	}

	public DcfsGgtsJbxx getDcfsGgtsJbxx() {
		return dcfsGgtsJbxx;
	}

	public void setDcfsGgtsJbxx(DcfsGgtsJbxx dcfsGgtsJbxx) {
		this.dcfsGgtsJbxx = dcfsGgtsJbxx;
	}
	
	
	
	
}
